(function(app){
	app
		.controller("end_mainCtrl",["$scope","myFactory",'$http','$stateParams','$state','$timeout','$ionicHistory',"$q",function($scope,myFactory,$http,$stateParams,$state,$timeout,$ionicHistory,$q){
			
			//接收参数、定义参数
			var chdrnum01=$stateParams.chdrnum01;
			var chdrcoy = $stateParams.chdrcoy;
			var itemId=$stateParams.itemId;  //这里用于如果是单个变更项的时候，可以直接方便快捷使用showSingleItem(itemId);
//			var strItemIds=$stateParams.strItemIds;
			var strItemIds = "";
//			var endData=$stateParams.endData;;//用于读取initRest返回的数据，里面包括很多数据，包括每一项更改（item01、item02_2）的内容
			var endData= "";
//			var policy=$stateParams.policy;
			var policy = "";
			var charge="";//收付费账户信息
			var chargeType="";
			var signMainData=$stateParams.signMainData;//用于返回
			var photoMainData = $stateParams.photoMainData;//用于返回
			var initFlag = false;//检测标志，在初始化函数完成后，会被置为true
			var _checkFlag = "N" ;	//	电子邮件是否被占用标示[Y-占用，N-没有占用]
			var _lasFlag = "Y" ;	//	LAS初始化为Y
			var searchParam = { //如果结案失败，往回跳查询页面时候带的初始封装参数
					bdhNo:chdrnum01,
					birthday:"",
					name:"",
					secuityno:"",
					tab:"1", //默认保单查询
					type:1 //默认通过保单号查询
			}
			//绑定数据
			$scope.chdrnum01=$stateParams.chdrnum01;
//			$scope.itemCommonList=$stateParams.itemCommonList;
//			$scope.endData=$stateParams.endData;   //初始化在photoMain的JS做的时候使用
//			$scope.end=$stateParams.endData.end;
			$scope.isEndMainPage =true;//只有endMain页面，嵌入页面才显示显示标题
			$scope.FlagFor40Check =false;//控制是否显示其他的 “生存给付方式”模块消息，默认不显示
			/*任务17 额外投资，标志初始化begin*/
			$scope.InvAmntFlag = false; //万能区域，隐藏
			$scope.UniAmntFlag = false; //投连区域：金额，显示
			$scope.AcctFlag = false;    //投连区域：产品选择区域，显示
			/*任务17 额外投资，标志初始化end*/
			/*任务21部分提取，标志初始化begin*/
			$scope.universalDiv21CheckFlag = false;
			$scope.investDiv21CheckFlag = false;
			/*任务21部分提取，标志初始化end*/
			
			var isCommitted = false;//表单是否已经提交标识，默认为false
			//var tokenEndAuthorId=$stateParams.tokenEndAuthorId;
			var tokenEndAuthorId="A";
			
			/*S2019042908337营运系统反洗钱工作差异分析系统优化需求 add by yangyan 20190712 start*/
			$scope.changeFlag = false;
			/*S2019042908337营运系统反洗钱工作差异分析系统优化需求 add by yangyan 20190712 end*/
			
			/*S2019051508554《反洗钱监管-官微、移动保全增加核实投被保险关系功能需求》 add by yangyan 20190712 start*/
			$scope.peoRelationFlag = false;
			/*S2019051508554《反洗钱监管-官微、移动保全增加核实投被保险关系功能需求》 add by yangyan 20190712 end*/
			
			//S2019060408807保全退保项目删除预估应退金额需求 add by yangyan 20200213 start
			$scope.payFeeShowFlag = true;
			$scope.refundedShowFlag = false;
			//S2019060408807保全退保项目删除预估应退金额需求 add by yangyan 20200213 end
			
			//初始化
			$scope.showAccountFlag = false;//是否显示收付费账户信息，默认不显示
			$scope.showAccountIntimeFlag = false;//是否显示实时付费
			$scope.showFlag = false;//隐藏多项变更内容列表
			$scope.data = {
				changeList: [
				]
			};
			var token=sessionStorage.getItem("token");
			
/***********************************************初始化函数部分begin****************************************************/
			$scope.load = function () {
				myFactory.loadingShow();
				var timestamp=myFactory.getTimetamp();
				var sfis= "token-timestamp";
				var signStr="token="+token+"&timestamp="+timestamp;//encodeURI(name)
				var sign = myFactory.hex(signStr);
				$http({
					method: 'GET',
					url: app.domain + 'end/initRest.action',
					params: {'sign':sign,'sfis':sfis,'token':token,'timestamp':timestamp}
				}).then(function successCallback(response) {
					if (response.data.success) {
						endData=response.data.data.endData;
						$scope.endData=response.data.data.endData;
						$scope.end=$scope.endData.end;
						$scope.itemCommonList = response.data.data.endData.itemCommonList;
						policy=response.data.data.policy;
						charge = policy.charge;
						strItemIds = response.data.data.strItemIds;
						
						//结案授权凭证id-一次使用后失效
						//tokenEndAuthorId=response.data.data.tokenEndAuthorId;
						
						if(""!=strItemIds && null!=strItemIds && undefined != strItemIds){
							var strItemIdsSplit=strItemIds.split(",");
							if(strItemIdsSplit.length==1){//控制列表隐藏，显示单列表界面
								//显示当前itemId-->指针【再封装一个方法显示具体哪一个指针】
								console.log("end 单个变更确认---->>>");
								//$scope.showFlag=false;//隐藏多项变更内容列表
	
								/**********************************测试阶段使用begin****************************/
								/*if(app.openFlag=='openAll'){
									console.log("Permission：开发人员");
									$scope.showFlag=true;//开发测试,【备注：上传svn必须还原为false】
								}else if(app.openFlag=='openTest'){
									console.log("No Permission：测试人员");
								    $scope.showFlag=false;//隐藏多项变更内容列表
								}*/
								$scope.showFlag=false;//隐藏多项变更内容列表
								/**********************************测试阶段使用end****************************/
								//$scope.showFlag=true;//开发测试,【备注：上传svn必须还原为false】
								showSingleItem(itemId);
							}else{
								$scope.showFlag=true;//显示多项变更内容列表
							}
						}
						
						//收付费账户信息部分初始化
						var isCSWD ="";
						if(endData.item40!=null && endData.item40!=undefined &&  endData.item40!=""){
							isCSWD = endData.item40.beneList[0].zdivOpt;
						}
						
						if(charge != null &&  charge != undefined && charge != ""){
							chargeType=charge.chargeType;
							if(chargeType=='1'){//实时缴费
								$scope.showAccountIntimeFlag = true;
							}
							if(chargeType=='2'){//非实时缴费
								$scope.showAccountIntimeFlag = false;
								
								$scope.showAccountFlag = true;//显示收付费账户信息
								var strItemIdsSplit=strItemIds.split(",");
								for(var i=0 ;i<strItemIdsSplit.length;i++){
									if(strItemIdsSplit[i]=="39" || (strItemIdsSplit[i]=="40" && "CSWD"==isCSWD)){//当类型为生存给付确认 、生存领取方式，不显示收付费账户信息
										$scope.showAccountFlag = false;
									}
								}
								//填充数据
								var accountFlag = charge.accountFlag;
								if(accountFlag=="1"){//如果是选择的是续期账户
									$scope.typeName = "续期账户";  //类型
									$scope.paynme = charge.paynme1; //名字
									$scope.bankdesc = charge.bankdesc1; //银行
									$scope.citydesc = charge.citydesc1;//开户城市
									$scope.bankacctkey = charge.bankacctkey1;//账号
								}else if(accountFlag=="3"){//如果选择的是首期缴费账户
									$scope.typeName = "首期缴费账户";
									$scope.paynme = charge.paynme3;
									$scope.bankdesc = charge.bankdesc3;
									$scope.citydesc = charge.citydesc3;
									$scope.bankacctkey = charge.bankacctkey3;//账号
								}else if(accountFlag=="2"){//如果选择的是其他账户
									$scope.typeName = "其他账户";
									$scope.paynme = charge.paynme;
									$scope.bankdesc = charge.bankdesc;
									$scope.citydesc = charge.citydesc;
									$scope.bankacctkey = charge.bankacctkey;//账号
								}
							}
						}
						
						//页面部分逻辑控制处理
						$scope.emailShowFlag=false;
						//var _checkFlag = "N" ;	//	电子邮件是否被占用标示[Y-占用，N-没有占用]
						/*var show=endData.esflag;
						if(show=="N"){
							$("#show").show();
						}else if(show=='Y'){
						}*/
						var esemail=$scope.end.esemail;
						if(esemail!=null && esemail!=undefined && esemail!=""){//有邮箱，显示邮箱，且不允许修改===>邮箱为空，不允许禁用录入，结案按钮又设置不允许为空，逻辑不对的
							$("#esemail").attr("readonly","true");
						}
	
						if(endData.pendingFlag!='B'){//如果状态不为B类，不需要人工审核的
							$scope.emailShowFlag=true;//则允许显示电子邮箱方式领取批单
							//同时默认勾选
							$("#emailrdo").attr("checked",true);
							$("#esemail").val($scope.end.esemail);
						}
						//S2018122906735移动保全新增变更项目及功能的优化需求 add by mqz 20200901 start
						//转人工
						if(strItemIds.indexOf('29') >= 0||strItemIds.indexOf('30') >= 0||strItemIds.indexOf('15') >= 0){
					          $scope.emailShowFlag=false;
				        }
						// S2018122906735移动保全新增变更项目及功能的优化需求 add by mqz 20200901 end
						initFlag=true;//标识初始化成功
						myFactory.loadingHide();
					}else{
						myFactory.loadingHide();
						myFactory.alert('','系统没有响应，请返回重试','info');
					}
				}, function errorCallback(response) {
					myFactory.loadingHide();
					myFactory.alert('','访问后台失败，请返回重试','info');
				});
			}

/***********************************************初始化函数部分end****************************************************/
			
//获取方式再次改回在本页面初始化方式得到 By ZZQ 2017-9-7
//			//页面部分逻辑控制处理
//			$scope.emailShowFlag=false;
//			var _checkFlag = "N" ;	//	电子邮件是否被占用标示[Y-占用，N-没有占用]
//			var show=endData.esflag;
//			if(show=="N"){
//				$("#show").show();
//			}else if(show=='Y'){
//				$("#esemail").attr("readonly","true");
//			}
//
//			if(endData.pendingFlag!='B'){
//				$scope.emailShowFlag=true;
//			}

			//变更end_main页面获取数据方式 20170717         获取方式再次改回在本页面初始化方式得到 By ZZQ 2017-9-7
//			charge = policy.charge;
//			if(""!=strItemIds && null!=strItemIds && undefined != strItemIds){
//				var strItemIdsSplit=strItemIds.split(",");
//				if(strItemIdsSplit.length==1){//控制列表隐藏，显示单列表界面
//					//显示当前itemId-->指针【再封装一个方法显示具体哪一个指针】
//					console.log("end 单个变更确认---->>>");
//					//$scope.showFlag=false;//隐藏多项变更内容列表
//
//					/**********************************测试阶段使用begin****************************/
//					if(app.openFlag=='openAll'){
//						console.log("Permission：开发人员");
//						$scope.showFlag=true;//开发测试,【备注：上传svn必须还原为false】
//					}else if(app.openFlag=='openTest'){
//						console.log("No Permission：测试人员");
//						$scope.showFlag=false;//隐藏多项变更内容列表
//					}
//					/**********************************测试阶段使用end****************************/
//
//					//$scope.showFlag=true;//开发测试,【备注：上传svn必须还原为false】
//
//					showSingleItem(itemId);
//				}else{
//					$scope.showFlag=true;//显示多项变更内容列表
//				}
//			}

			//收付费账户信息部分初始化   获取方式再次改回在本页面初始化方式得到 By ZZQ 2017-9-7
//			var isCSWD ="";
//			if(endData.item40!=null && endData.item40!=undefined &&  endData.item40!=""){
//				isCSWD = endData.item40.beneList[0].zdivOpt;
//			}
//			if(charge != null &&  charge != undefined && charge != ""){
//				$scope.showAccountFlag = true;//显示收付费账户信息
//				var strItemIdsSplit=strItemIds.split(",");
//				for(var i=0 ;i<strItemIdsSplit.length;i++){
//					if(strItemIdsSplit[i]=="39" || (strItemIdsSplit[i]=="40" && "CSWD"==isCSWD)){//当类型为生存给付确认 、生存领取方式，不显示收付费账户信息
//						$scope.showAccountFlag = false;
//					}
//				}
//				//填充数据
//				var accountFlag = charge.accountFlag;
//				if(accountFlag=="1"){//如果是选择的是续期账户
//					$scope.typeName = "续期账户";  //类型
//					$scope.paynme = charge.paynme1; //名字
//					$scope.bankdesc = charge.bankdesc1; //银行
//					$scope.citydesc = charge.citydesc1;//开户城市
//					$scope.bankacctkey = charge.bankacctkey1;//账号
//				}else if(accountFlag=="3"){//如果选择的是首期缴费账户
//					$scope.typeName = "首期缴费账户";
//					$scope.paynme = charge.paynme3;
//					$scope.bankdesc = charge.bankdesc3;
//					$scope.citydesc = charge.citydesc3;
//					$scope.bankacctkey = charge.bankacctkey3;//账号
//				}else if(accountFlag=="2"){//如果选择的是其他账户
//					$scope.typeName = "其他账户";
//					$scope.paynme = charge.paynme;
//					$scope.bankdesc = charge.bankdesc;
//					$scope.citydesc = charge.citydesc;
//					$scope.bankacctkey = charge.bankacctkey;//账号
//				}
//			}

			//重新受理
			$scope.renew = function(){
				myFactory.renew();
			}
			//退出移动保全
			$scope.exit = function(){
				myFactory.exit();
			}

			$scope.goBack = function () {
				//history.go(-1);
				//$("#hidenId").hide();
				//myFactory.goBack();
				//结案前返回上一步骤必须重新计算
//				$ionicHistory.clearCache().then(function(){  不能只返回到留影界面，而是要返回到签名界面 By ZZQ 2017-9-5
//					$state.go('photo_main',{
//						itemId:itemId,
//						chdrnum01:chdrnum01,
//						chdrcoy:chdrcoy,
//						photoMainData:photoMainData,
//						signMainData:signMainData
//					});
//				})
				var timestamp=myFactory.getTimetamp();
				var sfis= "itemId-token-timestamp";
				var signStr="itemId="+itemId+"&token="+token+"&timestamp="+timestamp;//encodeURI(name)
				var sign = myFactory.hex(signStr);
				/*签名留影*/
				$http({
					method: 'GET',
					url: app.domain + "img/gotoSignMain.action",
					params: {"itemId": itemId,'sign':sign,'sfis':sfis,'token':token,'timestamp':timestamp}
				}).then(function successCallback(response) {
					if (response.data.success) {
						var signMainDataBack = response.data.data.signMainData;
						if(signMainData!=undefined && signMainData!=null && signMainData!=""){
							$ionicHistory.clearCache().then(function(){
								$state.go('photo_sign',{
									itemId:itemId,
									chdrnum01:chdrnum01,
									chdrcoy:chdrcoy,
									signMainData:signMainDataBack
								});
							});
						}
					}
				}, function errorCallback(response) {
					myFactory.alert("","访问后台出错，请稍后再试!","info");
				});
			}

			//保单详情弹窗
			$scope.showPolicyDetail = function(){
				modal('open','policyModalOnEndMain','policyWindowOnEndMain','policyCloseXOnEndMain');
				var timestamp=myFactory.getTimetamp();
				var sfis= "chdrnum-chdrcoy-token-timestamp";
				var signStr="chdrnum="+chdrnum01+"&chdrcoy="+chdrcoy+"&token="+token+"&timestamp="+timestamp;//encodeURI(name)
				var sign = myFactory.hex(signStr);
				//初始化查询订单详情
				var policyData;
				$http({
					method: 'GET',
					url: app.domain + 'query/restFindPolicyDetail.action',
					params: {'chdrnum': chdrnum01,'chdrcoy': chdrcoy,'sign':sign,'sfis':sfis,'token':token,'timestamp':timestamp}
				}).then(function successCallback(response) {
					if (response.data.success) {
						policyData = response.data.data;
						$scope.policyData = policyData;
						$scope.policyData.ptdate01=myFactory.DateTools($scope.policyData.ptdate01);
					}
				}, function errorCallback(response) {
					$.alert({
						title: '',
						text: '初始化查询订单详情失败!',
						onOK: function () {
							//点击确认
						}
					});
				});

			}
			//保单详情弹窗关闭函数
			$scope.policyCancelOnEndMain = function(){
				modal('close','policyModalOnEndMain','policyWindowOnEndMain','policyCloseXOnEndMain');
			}
			//查看受益人详情
			$scope.befDetailMode = function(index){
				modal('open','befPeopleModalOnEndMain','policyWindowOnEndMain','befPeopleModalCloseXOnEndMain');
				var befDetail = $scope.benefit[index];
				$scope.befDetail = befDetail;
			}
			//受益人详情弹窗关闭函数
			$scope.befPeopleCancelOnEndMain = function(){
				modal('close','befPeopleModalOnEndMain','policyWindowOnEndMain','befPeopleModalCloseXOnEndMain');
			}
			
//			//结案异常弹出框  太鸡儿丑了，不用这种方式了
//			$scope.attentionModeOpen = function(index){
//				modal('open','attention','policyWindowOnEndMainForAttention','');
//				var befDetail = $scope.benefit[index];
//				$scope.befDetail = befDetail;
//			}
//			//结案异常弹出框关闭
//			$scope.attentionModeClose = function(){
//				modal('close','attention','policyWindowOnEndMainForAttention','');
//			}
//			//结案异常点击确定函数
//			$scope.returnToSearch = function(){
//				$scope.attentionModeClose();//关闭弹窗
//				//定向跳转
//				$ionicHistory.clearCache().then(function(){
//					$state.go('search',{
//						searchParam:null
//					});
//				});
//			}
			//关闭遮罩
			$scope.overwindowClose = function(){
				//$(".overwindow").show();
				$(".overwindow").hide();
				$(".overmodal").hide();
			}
			//生存给付详情弹框
			$scope.beneDetailModal = function(index){
				$("#beneClntDialogOnEndMain").fadeToggle(50);
				
				//能点详情弹框触发这个函数说明已经有数据，不需要对数据进行判断，这里为具体读出数组第index个
				$scope.beneDetail = $scope.item39.beneList[index];
				
				$("#beneClntDialogOnEndMain .myDialog_content .btn_close").click(function(){
					$(this).parents('#beneClntDialogOnEndMain').fadeOut(50);
				});
				
				$("#beneClntDialogOnEndMain .myDialog_black").click(function(){
					$(this).parent('#beneClntDialogOnEndMain').fadeOut(50);
				});
			}
			//生存领取方式弹框
			$scope.beneDetailModalFor40Check = function(index){
				$("#beneDetailModalForItem40OnEndMain").fadeToggle(50);
				
				//能点详情弹框触发这个函数说明已经有数据，不需要对数据进行判断，这里为具体读出数组第index个
				$scope.beneDetailForItem40 = $scope.item40.beneList[index];

				$("#beneDetailModalForItem40OnEndMain .myDialog_content .btn_close").click(function(){
					$(this).parents('#beneDetailModalForItem40OnEndMain').fadeOut(50);
				});
				
				$("#beneDetailModalForItem40OnEndMain .myDialog_black").click(function(){
					$(this).parent('#beneDetailModalForItem40OnEndMain').fadeOut(50);
					//$.toast("信函接收方式没有改变不需要改变", "text");
				});
			}
			//领取给付金 受益人详情触发函数
			$scope.expirationDetailDialog = function(index){
				//与生存领取方式弹框一样，这里直接引用生存领取方式的HTML元素
				$("#beneDetailModalForItem40OnEndMain").fadeToggle(50);
				
				//能点详情弹框触发这个函数说明已经有数据，不需要对数据进行判断，这里为具体读出数组第index个
				$scope.beneDetailForItem40 = $scope.item43.showList[index];//虽然沿用生存领取方式的HTML元素，但注意数据来源不同

				$("#beneDetailModalForItem40OnEndMain .myDialog_content .btn_close").click(function(){
					$(this).parents('#beneDetailModalForItem40OnEndMain').fadeOut(50);
				});
				
				$("#beneDetailModalForItem40OnEndMain .myDialog_black").click(function(){
					$(this).parent('#beneDetailModalForItem40OnEndMain').fadeOut(50);
				});
			}
			//领取生存金：详情
			$scope.benifidDetailMain = function(index){
				console.log("index:"+index);
				$("#get_survival_dialog1EndMain").fadeToggle(50);

				var benifidContent = $scope.item47.beneList[index];

				$scope.clientNameContent=benifidContent.clientName;
				/*$scope.clientNoContent=benifidContent.clientNo;*/
				$scope.clientNoContent=benifidContent.idCard;//获取的是客户证件号码，不是客户号，客户号属于敏感数据

				$("#get_survival_dialog1EndMain .myDialog_content .btn_close").click(function(){
					$(this).parents('#get_survival_dialog1EndMain').fadeOut(50);
				});

				$("#get_survival_dialog1EndMain .myDialog_black").click(function(){
					$(this).parent('#get_survival_dialog1EndMain').fadeOut(50);
				});
			}
			
			//变更后项目内容
			$scope.showChangeInfo = function(itemId){
				if(itemId=="01"){//通讯方式
					var item01=endData.item01;
					$state.go('content_01_check',{
						item01:item01,chdrnum01:chdrnum01,chdrcoy:chdrcoy
					});
				}
				if(itemId=="02_1"){
					var item02_1=endData.item02_1;
					$state.go('content_02_1_check',{
						itemId:itemId,
						item02_1:item02_1,
						chdrnum01:chdrnum01,
						chdrcoy:chdrcoy
					});
				}
				if(itemId=="02_2"){
					var item02_2=endData.item02_2;
					$state.go('content_02_2_check',{
						itemId:itemId,
						item02_2:item02_2,
						chdrnum01:chdrnum01,
						chdrcoy:chdrcoy
					});
				}
				if(itemId=="03"){//进入变更签名
					var item03=endData.item03;
					if(item03.signroleNm.trim()=="被保人签名"){
						item03.signroleNm = "被保险人签名";
					}
					$state.go('content_03_check',{
						itemId:itemId,
						item03:item03,
						chdrnum01:chdrnum01,
						chdrcoy:chdrcoy
					});
				}
				if(itemId=="04"){//缴费方式
					var item04=endData.item04;
					$state.go('content_04_check',{
						itemId:itemId,
						item04:item04,
						chdrnum01:$scope.chdrnum01,
						chdrcoy:chdrcoy
					});
				}
				if(itemId=="05"){//变更现金红包领取方式
					var item05=endData.item05;
					$state.go('content_05_check',{
						itemId:itemId,
						item05:item05,
						chdrnum01:chdrnum01,
						chdrcoy:chdrcoy
					});
				}
				if(itemId=="06"){//保费逾期未付   保险费逾期未付选择
					var item06=endData.item06;
					$state.go('content_06_check',{
						itemId:itemId,
						item06:item06,
						chdrnum01:$scope.chdrnum01,
						chdrcoy:chdrcoy
					});
				}
				if(itemId=="08"){//身故受益人
					var item08=endData.item08;
					$state.go('content_08_check',{
						itemId:itemId,
						item08:item08,
						chdrnum01:$scope.chdrnum01,
						chdrcoy:chdrcoy
					});
				}
				if(itemId=="10"){//更改个人身份资料
					var item10 = endData.item10;
					/*var clientCount=itemData.item10.clientCount;
					 $scope.client_LF = itemData.item10.clientList[0];
					 if(clientCount>1){
					 $scope.show10TbrFlag=true; //显示更改个人身份资料-投保人
					 $scope.client_OW = itemData.item10.clientList[1];
					 }*/
					$state.go('content_10_check',{
						chdrnum01:chdrnum01,
						chdrcoy:chdrcoy,
						item10:item10,
					});
				}
				if(itemId=="12_42" || itemId=="12" || itemId=="42"){//补发尊贵客户卡
					var item42=endData.item42;
					var item12=endData.item12;
					if((item42==undefined || item42=="")){//投保人
						item42="";
					}
					if((item12==undefined || item12=="")){//被保险人
						item12="";
					}
					$state.go('content_12_42_check',{chdrnum01 : chdrnum01,chdrcoy : chdrcoy,item42 : item42,item12 : item12,policy:policy});
				}
				if(itemId=="17"){//额外投资
					var item17=endData.item17;
					$state.go('content_17_check',{chdrnum01 : chdrnum01,chdrcoy : chdrcoy,item17:item17});
				}
				if(itemId=="19"){//投资账户转换
					var item19=endData.item19;
					$state.go('content_19_check',{chdrnum01 : chdrnum01,chdrcoy : chdrcoy,item19:item19});
				}
				if(itemId=="20"){//投资账户选择
					var item20=endData.item20;
					$state.go('content_20_check',{chdrnum01 : chdrnum01,chdrcoy : chdrcoy,item20:item20});
				}
				if(itemId=="21"){//部分提取
					var item21=endData.item21;
					$state.go('content_21_check',{chdrnum01 : chdrnum01,chdrcoy : chdrcoy,item21:item21});
				}
				if(itemId=="23"){//复效
					var item23=endData.item23;
					$state.go('content_23_check',{chdrnum01 : chdrnum01,chdrcoy : chdrcoy,item23:item23});
				}
				if(itemId=="27"){//退保
					var item27=endData.item27;
					$state.go('content_27_check',{chdrnum01 : chdrnum01,chdrcoy : chdrcoy,item27:item27});
				}
				if(itemId=="28"){//保单借款
					var item28=endData.item28;
					$state.go('content_28_check',{chdrnum01 : chdrnum01,chdrcoy : chdrcoy,item28:item28});
				}
				if(itemId=="33"){//结束缓缴期
					var item33=endData.item33;
					$state.go('content_33_check',{chdrnum01 : chdrnum01,chdrcoy : chdrcoy, item33:item33});
				}
				if(itemId=="34"){//终止合同结清
					var item34=endData.item34;
					$state.go('content_34_check',{chdrnum01 : chdrnum01,chdrcoy : chdrcoy, item34:item34});
				}
				if(itemId=="35"){//补发保险合同
					$state.go('content_35_check',{chdrnum01 : chdrnum01,chdrcoy : chdrcoy});
				}
				if(itemId=="36"){//进入保险费缓缴期
					$state.go('content_36_check',{
						chdrnum01 : chdrnum01,
						chdrcoy : chdrcoy
					});
				}
				if(itemId=="37"){//补缴保险费用
					var item37=endData.item37;
					$state.go('content_37_check',{
						item37:item37,
						chdrnum01 : chdrnum01,
						chdrcoy : chdrcoy
					});
				}
				if(itemId=="38"){
					var item38=endData.item38;
					$state.go('content_38_check',{
						itemId:itemId,
						item38:item38,
						chdrnum01:chdrnum01,
						chdrcoy:chdrcoy
					});
				}
				if(itemId=="39"){//进入生存给付
					var item39=endData.item39;
					$state.go('content_39_check',{
						item39:item39,
						chdrnum01 : chdrnum01,
						chdrcoy : chdrcoy
					});
				}
				if(itemId=="40"){//生存领取方式  生存给付资料变更
					var item40=endData.item40;
					$state.go('content_40_check',{
						item40:item40,
						chdrnum01 : chdrnum01,
						chdrcoy : chdrcoy
					});
				}
				if(itemId=="43"){//领取满期金  满期给付确认
					var item43=endData.item43;
					$state.go('content_43_check',{
						item43:item43,
						chdrnum01 : chdrnum01,
						chdrcoy : chdrcoy
					});
				}
				if(itemId=="45"){//领取红利
					var item45=endData.item45;
					$state.go('content_45_check',{
						item45:item45,
						chdrnum01 : chdrnum01,
						chdrcoy : chdrcoy
					});
				}
				if(itemId=="47"){//领取生存金
					var item47=endData.item47;
					$state.go('content_47_check',{
						item47:item47,
						chdrnum01:chdrnum01,
						chdrcoy:chdrcoy
					});
				}
				if(itemId=="50"){//更改年金领取方式
					var item50=endData.item50;
					$state.go('content_50_check',{chdrnum01 : chdrnum01,chdrcoy : chdrcoy,item50:item50});
				}				
				if(itemId=="52"){//续期缴费通知
					var item52=endData.item52;
					$state.go('content_52_check',{chdrnum01 : chdrnum01,chdrcoy : chdrcoy,item52:item52});
				}
				if(itemId=="54"){//信函接收方式
					var item54=endData.item54;
					$state.go('content_54_check',{chdrnum01 : chdrnum01,chdrcoy : chdrcoy,item54:item54});
				}
				if(itemId=="55"){//犹豫期退保
					var item55=endData.item55;
					$state.go('content_55_check',{chdrnum01 : chdrnum01,chdrcoy : chdrcoy,item55:item55});
				}
				//S2018122906735移动保全新增变更项目及功能的优化需求 add by mqz 20191225 start
			    if(itemId=="15"){
			    	var item15=endData.item15;
					$state.go('content_15_check',{chdrnum01 : chdrnum01,chdrcoy : chdrcoy,item15:item15});
			    }
			    if(itemId=="29"){
			    	var item29=endData.item29;
					$state.go('content_29_check',{chdrnum01 : chdrnum01,chdrcoy : chdrcoy,item29:item29});
			    }
			    if(itemId=="30"){//补充告知
					var item30=endData.item30;
					$state.go('content_30_check',{chdrnum01 : chdrnum01,chdrcoy : chdrcoy,item30:item30});
				}

			}

			
			//如果变更项只有一项，则直接显示详情内容，不再需要跳转
			function showSingleItem(tempItemId) {
				//映射到页面
				if("01"==tempItemId){
					//$scope.showContent01Flag=true;
					$("content01").show();
					$scope.item01 = endData.item01;
					//同时变更保单字段一行三个保单号
					var strs01= new Array(); //定义一数组 
					strs01=endData.item01.inPolicynos.split(","); //字符分割 
					for(var i=0;i<=strs01.length-1;i++){
						if(i!=strs01.length-1){
							strs01[i]=strs01[i]+',';
						}
					}
					$scope.strs01 = strs01;
				}
				if("02_1"==tempItemId){
					//$scope.showContent02_1Flag=true; //显示“进入终止续期转账授权”指令标签
					$("content0201").show();
					$scope.item02_1 = endData.item02_1;
					//同时变更保单字段一行三个保单号
					var strs02_1= new Array(); //定义一数组 
					strs02_1=endData.item02_1.changechdrnums.split(","); //字符分割 
					for(var i=0;i<=strs02_1.length-1;i++){
						if(i!=strs02_1.length-1){
							strs02_1[i]=strs02_1[i]+',';
						}
					}
					$scope.strs02_1 = strs02_1;
					/*S2019042908337营运系统反洗钱工作差异分析系统优化需求 add by yangyan 20190712 start*/
					if ("" != endData.item02_1.changeCon && null != endData.item02_1.changeCon) {
						$scope.changeFlag = true;
					}
					/*S2019042908337营运系统反洗钱工作差异分析系统优化需求 add by yangyan 20190712 end*/
				}
				if("02_2"==tempItemId){
					//$scope.showContent02_2Flag=true; //显示“进入终止续期转账授权”指令标签
					$("content0202").show();
					$scope.item02_2 = endData.item02_2;
				}
				if("03"==tempItemId){
					//$scope.showContent03Flag=true; //显示“变更签名”指令标签
					$("content03").show();
					$scope.item03 = endData.item03;
					if($scope.item03.signroleNm.trim()=="被保人签名"){
						$scope.item03.signroleNm = "被保险人签名";
					}
				}
				if("04"==tempItemId){
					//$scope.showContent04Flag=true; //显示“缴费方式”指令标签
					$("content04").show();
					$scope.item04 = endData.item04;
					var b=$scope.item04.billFreq;
					if(b=="01"){
						//document.getElementById('jb').innerHTML="年缴";
						$scope.billFreqName="年缴";
					}
					if(b=="02"){
						$scope.billFreqName="半年缴";
					}
					if(b=="04"){
						$scope.billFreqName="季缴";
					}
					if(b=="12"){
						$scope.billFreqName="月缴";
					}
				}
				if("05"==tempItemId){
					//$scope.showContent05Flag=true; //显示“变更现金红利领取方式”指令标签
					$("content05").show();
					$scope.item05 = endData.item05;
				}
				if("06"==tempItemId){
					//$scope.showContent06Flag=true; //显示“变更现金红利领取方式”指令标签
					$("content06").show();
					$scope.item06 = endData.item06;
					var b=$scope.item06.autoPayFlag;
					if(b=="LAP"){
						$scope.payWay = "效力中止";
					}
					if(b=="APL"){
						$scope.payWay = "垫缴保费";
					}	
				}
				if("08"==tempItemId){
					//$scope.showContent08Flag=true; //显示“身故受益人”指令标签
					$("content08").show();
					$scope.benefit = endData.item08.benefit;
				}
				if("10"==tempItemId){
					$scope.show10TbrFlag=false; //默认隐藏更改个人身份资料-投保人
					//$scope.showContent10Flag=true; //显示更改个人身份资料
					$("content10").show();
					$scope.item10 = endData.item10;
					var clientCount=endData.item10.clientCount;
					$scope.client_LF = endData.item10.clientList[0];
					
				   //	S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
                    $scope.client_LF.availDataStart = DateTools($scope.client_LF.availDataStart);
				   // S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end

					//日期显示方式处理 by zzq 2018-3-6
					$scope.client_LF.availDataClose = DateTools($scope.client_LF.availDataClose);
					$scope.client_LF.birthDay = DateTools($scope.client_LF.birthDay);
					
					if(clientCount>1){
						$scope.show10TbrFlag=true; //显示更改个人身份资料-投保人
						$scope.client_OW = endData.item10.clientList[1];
//						S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 start
						$scope.client_OW.availDataStart = DateTools($scope.client_OW.availDataStart);
//						S2020120315839_增加记录证件有效期起始日  add by mqz 20210125 end
						//日期显示方式处理 by zzq 2018-3-6
						$scope.client_OW.availDataClose = DateTools($scope.client_OW.availDataClose);
						$scope.client_OW.birthDay = DateTools($scope.client_OW.birthDay);
					}
				}
				if("12_42"==tempItemId){
					//$scope.showFlag=false;//显示多项变更内容列表
					//$scope.showContent12_42Flag=true;
					$("content1242").show();

					//投/被保险人为同一人时，则只显示投保人信息
					//投/被保险人为同一人时，则只显示投保人勾选栏位
					//投保人证件号码
					var b=policy.base.secuityno;
					//被保人证件号码
					var b1=policy.base.rnIdNumber;
					var b2="";
					var b3="";
					//var applicant=itemData.applicant;
					//var benefitperson=itemData.benefitperson;
					var item42=endData.item42;
					var item12=endData.item12;
					if((item42!=undefined && item42!="")){//投保人
						b2=item42.servername;
					}
					if((item12!=undefined && item12!="")){//被保险人
						b3=item12.servername;
					}

					$scope.showTbrFlag_item42 = true;//默认显示投保人选项
					$scope.showBbrFlag_item12 = true;//显示被保人选项

					if(b==b1){
						$scope.showBbrFlag_item12 = false;//隐藏被保人选项
					}else{
						if(b3!=undefined && b3!=""){
							$scope.item12 = item12;
						}
					}
					if(b2==undefined || b2==""){
						$scope.showTbrFlag_item42 = false;//隐藏投保人选项
					}else{
						$scope.item42 = item42;
					}
					if(b3==undefined || b3==""){
						$scope.showBbrFlag_item12 = false;//隐藏被保人选项
					}else{
						$scope.item12 = item12;
					}

				}
				if("17"==tempItemId){
					//$scope.showContent17Flag=true; //额外投资
					$("content17").show();
					$scope.item17 = endData.item17;
					if($scope.item17.investList!=undefined && $scope.item17.investList!=null && $scope.item17.investList!=""){
						for(var i=0;i<$scope.item17.investList.length;i++){
							$scope.item17.investList[i].accountName=$scope.item17.investList[i].accountName.replace("投资账户","");
						}
					}
					var _productType = $scope.item17.productType;	//	产品类型，作为全局变量在开头已经定义
					//	存在投连产品时显示
					if( _productType.indexOf("U") > -1 ){
						//	取消隐藏
						$scope.InvAmntFlag = false; //万能区域，隐藏
						$scope.UniAmntFlag = true; //投连区域：金额，显示
						$scope.AcctFlag = true;    //投连区域：产品选择区域，显示

					}
					//	存在万能产品时显示		
					if( _productType.indexOf("W") > -1 ){
						//_InvAmnt.style.display ='';
						$scope.InvAmntFlag = true; //万能区域，显示
					}
				}
				if("19"==tempItemId){
					//$scope.showContent19Flag=true; //显示“投资账户转换”指令标签
					$("content19").show();
					var item19 = endData.item19;
					$scope.saleAccountList = item19.saleAccountChanges.saleAccountList;
					$scope.buyAccountList = item19.buyAccountCounts.buyAccountList;
					
					for(var i=0;i<$scope.saleAccountList.length;i++){
						$scope.saleAccountList[i].saleAccountName=$scope.saleAccountList[i].saleAccountName.replace("投资账户","");
						//console.log($scope.saleAccountList[i].saleAccountName);
					}
					for(var i=0;i<$scope.buyAccountList.length;i++){
						$scope.buyAccountList[i].buyAccountName=$scope.buyAccountList[i].buyAccountName.replace("投资账户","");
						//console.log($scope.buyAccountList[i].buyAccountName);
					}
					
				}
				if("20"==tempItemId){
					//$scope.showContent20Flag=true; //显示“投资账户转换”指令标签
					$("content20").show();
					$scope.item20 = endData.item20;
					for(var i=0;i<$scope.item20.length;i++){
						$scope.item20[i].accountName=$scope.item20[i].accountName.replace("投资账户","");
					}
				}
				if("21"==tempItemId){
					//$scope.showContent21Flag=true; //部分提取
					$("content21").show();
					$scope.item21 = endData.item21;
					if($scope.item21.accountList!=undefined && $scope.item21.accountList!=null && $scope.item21.accountList!=""){
						for(var i=0;i<$scope.item21.accountList.length;i++){
							$scope.item21.accountList[i].accountDesc=$scope.item21.accountList[i].accountDesc.replace("投资账户","");
						}
					}
					var _productType = $scope.item21.productType;	//	产品类型
					
					//	存在投连产品时显示
					if( _productType.indexOf("U") > -1 ){
						//$("#showContentFor21Check").html("本变更项预计应退金额（元）"); 
						$scope.item21.itemFee.showContent = "预计应退金额（元）";
						//	取消隐藏
						$scope.investDiv21CheckFlag = true;
					}
					//	存在万能产品时显示		
					if( _productType.indexOf("W") > -1 ){
						$scope.universalDiv21CheckFlag = true;
					}
				}
				if("23"==tempItemId){
					//$scope.showContent23Flag=true; //显示“复效”指令标签
					$("content23").show();
					$scope.item23 = endData.item23;
					var isAdd = $scope.item23.isAdd;
					$scope.show23bjItemFlag=false;
					if(isAdd!='O'){
						$scope.show23bjItemFlag=true;
						if(isAdd=='Y'){
							$scope.paymentOptions="补缴欠缴保险费";
						}else{
							$scope.paymentOptions="不补缴欠缴保险费";
						}
					}
				}
				if("27"==tempItemId){
					//$scope.showContent27Flag=true; //显示“退保”指令标签
					$("content27").show();
					$scope.item27 = endData.item27;
					/*S2019051508554《反洗钱监管-官微、移动保全增加核实投被保险关系功能需求》 add by yangyan 20190712 start*/
					if ("" != endData.item27.changeRelation && null != endData.item27.changeRelation) {
						$scope.peoRelationFlag = true;
					}
					/*S2019051508554《反洗钱监管-官微、移动保全增加核实投被保险关系功能需求》 add by yangyan 20190712 end*/
					
					//S2019060408807保全退保项目删除预估应退金额需求 add by yangyan 20200213 start
					if ('Y' == endData.item27.refundedFlag) {
						$scope.payFeeShowFlag = false;
					}
					//S2019060408807保全退保项目删除预估应退金额需求 add by yangyan 20200213 end
				}
				if("28"==tempItemId){
					//$scope.showContent28Flag=true; //显示“保单借款”指令标签
					$("content28").show();
					$scope.item28 = endData.item28;
				}
				if("33"==tempItemId){
					//$scope.showContent33Flag=true; //显示“结束缓缴期”指令标签
					$("content33").show();
					$scope.item33 = endData.item33;	
					if($scope.item33.switchInd == 'Y'){
						$scope.endType = true;
					}else if($scope.item33.switchInd == 'N'){
						$scope.endType = false;
					}
				}
				if("34"==tempItemId){
					//$scope.showContent34Flag=true; //显示“终止合同结清”指令标签
					$("content34").show();
					$scope.item34 = endData.item34;
					/*S2019051508554《反洗钱监管-官微、移动保全增加核实投被保险关系功能需求》 add by yangyan 20190712 start*/
					if ("" != endData.item34.changeRelation && null != endData.item34.changeRelation) {
						$scope.peoRelationFlag = true;
					}
					/*S2019051508554《反洗钱监管-官微、移动保全增加核实投被保险关系功能需求》 add by yangyan 20190712 end*/
				}
				if("35"==tempItemId){//补发保险合同
					//$scope.showFlag=false;//显示多项变更内容列表
					//$scope.showContent35Flag=true;
					$("content35").show();
					//$scope.itemData = itemData.item01;//没有item对象数据
				}
				
				if("36"==tempItemId){
					//$scope.showContent36Flag=true;
					$("content36").show();
				}
				if("37"==tempItemId){ //补缴保险费用
					//$scope.showContent37Flag=true;
					$("content37").show();
					$scope.item37 = endData.item37;
					for(var i=0;i<$scope.item37.investList.length;i++){
						$scope.item37.investList[i].investName=$scope.item37.investList[i].investName.replace("投资账户","");
					}
				}
				if("38"==tempItemId){ //进入保单还款
					//$scope.showContent38Flag=true;
					$("content38").show();
					$scope.item38 = endData.item38;
					var payMoney = $scope.item38.bamount ; //还款金额
					var needPayMoney = $scope.item38.amount ; //需还款金额
					if(payMoney == needPayMoney){
						$scope.payTypeOnItem38 = "全额还款";
					}else{
						$scope.payTypeOnItem38 = "部分还款";
					}
				}	
				if("39"==tempItemId){ //生存给付
					//$scope.showContent39Flag=true;
					$("content39").show();
					$scope.item39 = endData.item39;
					/*S2019051508554《反洗钱监管-官微、移动保全增加核实投被保险关系功能需求》 add by yangyan 20190712 start*/
					if ("" != endData.item39.changeRelation && null != endData.item39.changeRelation) {
						$scope.peoRelationFlag = true;
					}
					/*S2019051508554《反洗钱监管-官微、移动保全增加核实投被保险关系功能需求》 add by yangyan 20190712 end*/
				}
				if("40"==tempItemId){ //生存领取方式变更
					//$scope.showContent40Flag=true;
					$("content40").show();
					$scope.item40 = endData.item40;
					var value = $scope.item40.beneList[0].zdivOpt;
					if(value == 'CSWD'){//现金领取时，显示其他需要填写的信息
						$scope.FlagFor40Check = true;
					}else if(value == 'DVAC'){//储存生息/留存公司时候，隐藏其他需要填写的信息
						$scope.FlagFor40Check = false;
					}
					/*S2019051508554《反洗钱监管-官微、移动保全增加核实投被保险关系功能需求》 add by yangyan 20190712 start*/
					if ("" != endData.item40.changeRelation && null != endData.item40.changeRelation) {
						$scope.peoRelationFlag = true;
					}
					/*S2019051508554《反洗钱监管-官微、移动保全增加核实投被保险关系功能需求》 add by yangyan 20190712 end*/
				}
				if("43"==tempItemId){ //领取满期金   满期给付确认
					//$scope.showContent43Flag=true;
					$("content43").show();
					$scope.item43 = endData.item43;
					/*S2019051508554《反洗钱监管-官微、移动保全增加核实投被保险关系功能需求》 add by yangyan 20190712 start*/
					if ("" != endData.item43.changeRelation && null != endData.item43.changeRelation) {
						$scope.peoRelationFlag = true;
					}
					/*S2019051508554《反洗钱监管-官微、移动保全增加核实投被保险关系功能需求》 add by yangyan 20190712 end*/
				}
				if("45"==tempItemId){ //领取红利
					//$scope.showContent45Flag=true;
					$("content45").show();
					$scope.item45 = endData.item45;
				}
				if("47"==tempItemId){
					//$scope.showContent47Flag=true; //显示“领取生存金”指令标签
					$("content47").show();
					$scope.item47 = endData.item47;
					/*S2019051508554《反洗钱监管-官微、移动保全增加核实投被保险关系功能需求》 add by yangyan 20190712 start*/
					if ("" != endData.item47.changeRelation && null != endData.item47.changeRelation) {
						$scope.peoRelationFlag = true;
					}
					/*S2019051508554《反洗钱监管-官微、移动保全增加核实投被保险关系功能需求》 add by yangyan 20190712 end*/
				}
				if("50"==tempItemId){
					//$scope.showContent50Flag=true;
					$("content50").show();
					$scope.item50 = endData.item50;
					$scope.receiveTypeNme = endData.item50.receiveTypeNme;
				}
				if("52"==tempItemId){  //续期缴费通知
					//$scope.showContent52Flag=true;
					$("content52").show();
					$scope.item52 = endData.item52;
					//同时变更保单字段一行三个保单号
					var strs52= new Array(); //定义一数组 
					strs52=endData.item52.inPolicynos.split(","); //字符分割 
					for(var i=0;i<=strs52.length-1;i++){
						if(i!=strs52.length-1){
							strs52[i]=strs52[i]+',';
						}
					}
					$scope.strs52 = strs52;
				}
				if("54"==tempItemId){
					//$scope.showContent54Flag=true; //显示“退保”指令标签
					$("content54").show();
					$scope.item54 = endData.item54;
					var deliverOption=$scope.item54.deliverOption;
					if(deliverOption=='1'){
						$scope.deliverOptionContent='电子邮件';
					}else if(deliverOption=='2'){
						$scope.deliverOptionContent='纸质信函';
					}
				}
				if("55"==tempItemId){  //犹豫期退保
					//$scope.showContent55Flag=true;
					$("content55").show();
					$scope.item55 = endData.item55;
				}
			 	//S2018122906735移动保全新增变更项目及功能的优化需求 add by mqz 20191225 start 
				if("15"==tempItemId){  //保险计划
					$("content15").show();
					$scope.item15 = endData.item15;
					if ($scope.item15.benefit != null || $scope.item15.benefit != undefined) {
                    	if($scope.item15.benefit.length>0){
                    		$scope.newBenefit = true;
                        }
                    }
                    /*S2022013021184监管类-银行令〔2022〕1号营运相关系统功能需求 add by huanghaokun 20220315 start*/
                    if($scope.item15.reason!=null){
                   	 	$scope.reasonShow = true;
                    }
                    /*S2022013021184监管类-银行令〔2022〕1号营运相关系统功能需求 add by huanghaokun 20220315 end*/
				}
				if("30"==tempItemId){  //补充告知
					$("content30").show();
					$scope.item30 = endData.item30;
				}
				if("29"==tempItemId){//取消承保条件
					$("content29").show();
					$scope.item29 = endData.item29;
				}
			 	//S2018122906735移动保全新增变更项目及功能的优化需求 add by mqz 20191225 end 
			}


			$scope.end_verify = function () {
				if(isCommitted==false){
					console.log("正常提交结案控制："+isCommitted);
	                isCommitted = true;//提交表单后，将表单是否已经提交标识设置为true
	            }else{
	            	console.log("重复提交，禁止执行："+isCommitted);
	                return false;//返回false那么表单将不提交
	            }
				
				/*$("#InfoSubmit").addClass("disabled");
				$("#prev1,#prev2").addClass("disabled");*/
				if(!initFlag){
					isCommitted = false;
					//$("#prev1,#prev2").removeClass("disabled");					
					myFactory.alert("","初始化时失败，请返回上一步重试","info");
					myFactory.loadingHide();
					return;
				}
				
				var permitEnd=false;//是否允许结案
				//$("#noticeType").val();
				//var noticeType=$("#noticeType").val();//	结案通知方式[0-服务人员转交,1-电子邮件]
				var noticeType  = $("input[name='noticeType']:checked").val();
				console.log("noticeType:"+noticeType);

				//	校验结果
				var resultFlag  = true ;

				if(noticeType == undefined || noticeType == ""){
					isCommitted = false;
					myFactory.alert('','请选择批单领取方式','info');
					resultFlag = false;
					return resultFlag;
				}
				
				if(noticeType == "1"){
					if ($("#esemail").val()=="") {
						isCommitted = false;
						//$("#esemail").testRemind("请输入邮箱地址！");
						myFactory.alert('','请输入邮箱地址！','info');
						resultFlag = false;
						return resultFlag;
					}else if($("#esemail").val()!=""){
						var emailReg =/^([0-9a-zA-Z._]|-)+@{1}([0-9a-zA-Z._]|-)+\.{1}([0-9a-zA-Z._]|-)+$/;
						if (!emailReg.test($("#esemail").val().trim())) {
							isCommitted = false;
							//$("#esemail").testRemind("邮箱地址格式不正确！");
							myFactory.alert('','邮箱地址格式不正确！','info');
							resultFlag = false;
							return resultFlag;
						}
					}
				}

				//	选择电子邮件，且email被占用时
				if(resultFlag){
					/*_checkFlag=doOccupyCheck();
					_checkFlag.then(function success(_checkFlagReturn) {//成功回调
						console.log("_checkFlag1:"+_checkFlag);
						if( _checkFlag == "Y" && noticeType == "1" ){
							isCommitted = false;
							myFactory.alert('','电子邮件已经被占用！','info');
							resultFlag = false;
							console.log("resultFlag1:"+resultFlag);
							return resultFlag;
						}else{
							
						}
					},function error(_checkFlagErr) {//错误回调
						console.log(_checkFlagErr);
					});*/
					
					//	LAS检测
					if(resultFlag){
						_lasFlag = checkLAS();
						_lasFlag.then(function success(_lasFlagReturn) {//成功回调
							console.log("_lasFlag1:"+_lasFlag);
							if( _lasFlag != "Y" ){
								isCommitted = false;
								resultFlag = false;
								return resultFlag;
							}else{
								var esflag=$("#esflag").val();//	是否e-service用户[Y-是]
								//var esflag="N";
								var esemail=$("#esemail").val();//	电子邮件地址
								
								var clntnum=$scope.end.clntnum;//	客户号（投保人）
								var apstate=$scope.end.apstate;//	变更状态,[01-照会中，02-收费，03-留影，04-结案转人工，05-实时结案或非实时结案,06-实时结案错误]
								var flag01=$scope.end.flag01;//   核查状态：[1-待核查、2-复核通过、3-退件]
								
								var end={
										"noticeType":noticeType,
										"esflag":esflag,
										"esemail":esemail,
										"clntnum":clntnum,
										"apstate":apstate,
										"flag01":flag01,
										"tokenEndAuthorId":tokenEndAuthorId
								};
								var endItems={"endItems":end};
								
								console.log("resultFlag2:"+resultFlag);
								if(resultFlag){
									myFactory.loadingShow();
									//$timeout(function(){myFactory.loadingHide();},2000);
									var timestamp=myFactory.getTimetamp();
									var sfis= "token-timestamp";
									var signStr="token="+token+"&timestamp="+timestamp;//encodeURI(name)
									var sign = myFactory.hex(signStr);
									$http({
										method: 'post',
										url: app.domain + 'end/doEnd.action',
										data:{paramsMap:endItems,'sign':sign,'sfis':sfis,'token':token,'timestamp':timestamp}
									/*data:{end:end},
												headers:{'Content-Type': 'application/x-www-form-urlencoded'},
												transformRequest: function(obj) {
													var str = [];
													for(var p in obj){
														str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
													}
													return str.join("&");
												}*/
									}).then(function successCallback(response) {
										if (response.data.success) {
											var message=response.data.data.message;
											myFactory.loadingHide();
											$state.go('end_over',{
												chdrnum01:chdrnum01,
												message:message
											});
										}else{
											myFactory.loadingHide();
											//$scope.attentionModeOpen(); //自定义弹框方式，弹框样式不好看，这里不再采用
											$.alert({
												title: '', text: '系统繁忙，请稍后重试',
												onOK: function () {
													$ionicHistory.clearCache().then(function(){
														$state.go('search',{searchParam:searchParam});
													});
												}
											});
											$("#InfoSubmit").addClass("disabled");
											$("#prev1,#prev2").addClass("disabled");
										}
									}, function errorCallback(response) {
										myFactory.loadingHide();
										$.alert({
											title: '', text: '系统结案发生异常，请稍后重试',
											onOK: function () {
												$ionicHistory.clearCache().then(function(){
													$state.go('search',{searchParam:searchParam});
												});
											}
										});
										$("#InfoSubmit").addClass("disabled");
										$("#prev1,#prev2").addClass("disabled");
									});
								}
							}
						},function error(_checkFlagErr) {//错误回调
							console.log(_checkFlagErr);
						});	
					}
					
				}
			}

			$scope.setEmail = function (flag) {
				//function setEmail(flag){
				//console.log("触发,参数为"+flag);
				if(flag == "1"){
					$("#esemail").val("");
					//$("#esemail").addClass("disabled");
					$("#esemail").attr("disabled",true);
				}else{
					//$("#esemail").removeClass("disabled");
					$("#esemail").attr("disabled",false);
					$("#esemail").val($("#emailval").val());
				}
			}

			//转换日期方法  例如：20170225--->2017-02-25 by zzq 2018-3-6
			function DateTools(date){
				date = String(date) ;
				if($.trim(date)!=""){
					//S2020120315839_增加记录证件有效期起始日  add by mqz 20210722 start
					if(date=="99999999"){
						return "长期";
					}
					//S2020120315839_增加记录证件有效期起始日  add by mqz 20210722 end
					return date.replace(/^(\d{4})(\d{2})(\d{2})$/, "$1-$2-$3");
				}else{
					return date;
				}
			}
			
			
			//	校验电子邮件是否被e-service用户占用
			//$scope.doOccupyCheck = function () {
			function doOccupyCheck(){
				var deferred = $q.defer();//声明承诺
				var _esemail = $("#esemail").val();
				var _esflag  = $("#esflag").val();
				var url = app.domain+"end/doOccupyCheck.action";
				//	不是e-service用户时才检测
				if( "N" == _esflag ){
					/*ajaxReq(url,{"esemail":_esemail},"POST",false,function(text){
					 if( "Y" == eval(text) ){
					 _checkFlag = "Y" ;
					 $("#esemail").testRemind("电子邮件已经被占用！");
					 } else {
					 _checkFlag = "N" ;
					 }
					 });*/
					var timestamp=myFactory.getTimetamp();
					var sfis= "esemail-token-timestamp";
					var signStr="esemail="+_esemail+"&token="+token+"&timestamp="+timestamp;//encodeURI(name)
					var sign = myFactory.hex(signStr);
					$http({
						method: 'GET',
						url: url,
						params: {'esemail': _esemail,'sign':sign,'sfis':sfis,'token':token,'timestamp':timestamp}
					}).then(function successCallback(response) {
						if (response.data.success) {
							var checkFlagTemp=response.data.data.checkFlag;
							if("Y" == checkFlagTemp){
								//if( "Y" == eval(text) ){
								_checkFlag = "Y" ;
								//myFactory.alert('','电子邮件已经被占用！','info');
								console.log("_checkFlag0:"+_checkFlag);
							} else {
								_checkFlag = "N" ;
							}
						}
						deferred.resolve(response);//请求成功
					}, function errorCallback(response) {
						myFactory.alert('','电子邮件校验失败！','info');
					});
				}else{
					deferred.resolve("N");//请求成功
				}
				//return _checkFlag;
				return deferred.promise;//返回承诺
			}

			//	检测LAS是否开放
			function checkLAS(){
				var deferred = $q.defer();//声明承诺
				//var _lasFlag = "Y" ;	//	初始化为Y
				var url = app.domain+"common/restCheckLAS.action";
				//	同步校验
				/*ajaxReq(url,{"itemId":"00"},"POST",false,function(text){
				 _lasFlag = eval(text) ;	//	校验结果值
				 //	提示[LAS 尚未开放 请退出系统]
				 if( "N" ==  _lasFlag ){
				 $("#popSysMessage").popup("open");
				 }
				 });*/
				var timestamp=myFactory.getTimetamp();
				var sfis= "token-timestamp";
				var signStr="token="+token+"&timestamp="+timestamp;//encodeURI(name)
				var sign = myFactory.hex(signStr);
				$http({
					method: 'GET',
					url: url,
					params: {'sign':sign,'sfis':sfis,'token':token,'timestamp':timestamp}
				}).then(function successCallback(response) {
					if (response.data.success) {
						//测试放开时间时间点控制
						_lasFlag=response.data.data;
						if( "N" ==  _lasFlag ){//提示[LAS 尚未开放 请退出系统]
							myFactory.alert('','晚上22点至次日8点为公司日结作业时间段，日结期间系统暂停服务，不便之处，敬请谅解！','info');
						}
						console.log("_lasFlag0:"+_lasFlag);
					}
					deferred.resolve(response);//请求成功
				}, function errorCallback(response) {
					myFactory.alert('','系统发生异常！','info');
				});
				//return _lasFlag;
				return deferred.promise;//返回承诺
			}

		}]);


		app.directive('infoid',function(){
			return {
				restrict: 'EA',		//指明指令在DOM里面以什么形式被声明,EA.表示即可以是元素也可以是属性
				templateUrl: 'html/input/content_base_info.html',
				replace: true,		//设置解析后，DOM声明的指令是否消失
				link: function(scope,element,attrs){  //链接函数负责注册DOM事件和更新DOM,
					console.log('指令完成');
				}
			}
		});

		//详情指针
		/*app.directive('content01',function(){
			return {
				restrict: 'EA',		//指明指令在DOM里面以什么形式被声明,EA.表示即可以是元素也可以是属性
				templateUrl: 'html/input/input_check/check_01_content.html'+'?datestamp=' + (new Date()).getTime(),
				replace: true,		//设置解析后，DOM声明的指令是否消失
				link: function(scope,element,attrs){  //链接函数负责注册DOM事件和更新DOM,
					console.log('check-01-content指令完成');
				}
			}
		});
		app.directive('content0201',function(){
			return {
				restrict: 'EA',		//指明指令在DOM里面以什么形式被声明,EA.表示即可以是元素也可以是属性
				templateUrl: 'html/input/input_check/check_02_1_content.html'+'?datestamp=' + (new Date()).getTime(),
				replace: true,		//设置解析后，DOM声明的指令是否消失
				link: function(scope,element,attrs){  //链接函数负责注册DOM事件和更新DOM,
					console.log('check-02_1-content指令完成');
				}
			}
		});
		app.directive('content0202',function(){
			return {
				restrict: 'EA',		//指明指令在DOM里面以什么形式被声明,EA.表示即可以是元素也可以是属性
				templateUrl: 'html/input/input_check/check_02_2_content.html'+'?datestamp=' + (new Date()).getTime(),
				replace: true,		//设置解析后，DOM声明的指令是否消失
				link: function(scope,element,attrs){  //链接函数负责注册DOM事件和更新DOM,
					console.log('check-02_2-content指令完成');
				}
			}
		});
		app.directive('content03',function(){
			return {
				restrict: 'EA',
				templateUrl: 'html/input/input_check/check_03_content.html'+'?datestamp=' + (new Date()).getTime(),
				replace: true,
				link: function(scope,element,attrs){
					console.log('check-03-content指令完成');
				}
			}
		});

		app.directive('content04',function(){//缴费方式
			return {
				restrict: 'EA',
				templateUrl: 'html/input/input_check/check_04_content.html'+'?datestamp=' + (new Date()).getTime(),
				replace: true,
				link: function(scope,element,attrs){
					console.log('check-04-content指令完成');
				}
			}
		});

		app.directive('content05',function(){//变更现金红利领取方式
			return {
				restrict: 'EA',
				templateUrl: 'html/input/input_check/check_05_content.html'+'?datestamp=' + (new Date()).getTime(),
				replace: true,
				link: function(scope,element,attrs){
					console.log('check-05-content指令完成');
				}
			}
		});
		app.directive('content06',function(){//变更现金红利领取方式
			return {
				restrict: 'EA',
				templateUrl: 'html/input/input_check/check_06_content.html'+'?datestamp=' + (new Date()).getTime(),
				replace: true,
				link: function(scope,element,attrs){
					console.log('check-06-content指令完成');
				}
			}
		});
		app.directive('content08',function(){//身故受益人
			return {
				restrict: 'EA',
				templateUrl: 'html/input/input_check/check_08_content.html'+'?datestamp=' + (new Date()).getTime(),
				replace: true,
				link: function(scope,element,attrs){
					console.log('check-08-content指令完成');
				}
			}
		});
		app.directive('content10',function(){
			return {
				restrict: 'EA',
				templateUrl: 'html/input/input_check/check_10_content.html'+'?datestamp=' + (new Date()).getTime(),
				replace: true,
				link: function(scope,element,attrs){
					console.log('check-10-content指令完成');
				}
			}
		});
		app.directive('content1242',function(){
			return {
				restrict: 'EA',
				templateUrl: 'html/input/input_check/check_12_42_content.html'+'?datestamp=' + (new Date()).getTime(),
				replace: true,
				link: function(scope,element,attrs){
					console.log('check-12_42-content指令完成');
				}
			}
		});
		app.directive('content17',function(){
			return {
				restrict: 'EA',
				templateUrl: 'html/input/input_check/check_17_content.html'+'?datestamp=' + (new Date()).getTime(),
				replace: true,
				link: function(scope,element,attrs){
					console.log('check-17-content指令完成');
				}
			}
		});
		app.directive('content19',function(){
			return {
				restrict: 'EA',
				templateUrl: 'html/input/input_check/check_19_content.html'+'?datestamp=' + (new Date()).getTime(),
				replace: true,
				link: function(scope,element,attrs){
					console.log('check-19-content指令完成');
				}
			}
		});
		app.directive('content20',function(){
			return {
				restrict: 'EA',
				templateUrl: 'html/input/input_check/check_20_content.html'+'?datestamp=' + (new Date()).getTime(),
				replace: true,
				link: function(scope,element,attrs){
					console.log('check-20-content指令完成');
				}
			}
		});
		app.directive('content21',function(){
			return {
				restrict: 'EA',
				templateUrl: 'html/input/input_check/check_21_content.html'+'?datestamp=' + (new Date()).getTime(),
				replace: true,
				link: function(scope,element,attrs){
					console.log('check-21-content指令完成');
				}
			}
		});
		app.directive('content23',function(){ //复效
			return {
				restrict: 'EA',
				templateUrl: 'html/input/input_check/check_23_content.html'+'?datestamp=' + (new Date()).getTime(),
				replace: true,
				link: function(scope,element,attrs){
					console.log('check-23-content指令完成');
				}
			}
		});
		app.directive('content27',function(){ //退保
			return {
				restrict: 'EA',
				templateUrl: 'html/input/input_check/check_27_content.html'+'?datestamp=' + (new Date()).getTime(),
				replace: true,
				link: function(scope,element,attrs){
					console.log('check-27-content指令完成');
				}
			}
		});
		app.directive('content28',function(){
			return {
				restrict: 'EA',
				templateUrl: 'html/input/input_check/check_28_content.html'+'?datestamp=' + (new Date()).getTime(),
				replace: true,
				link: function(scope,element,attrs){
					console.log('check-28-content指令完成');
				}
			}
		});
		app.directive('content33',function(){
			return {
				restrict: 'EA',
				templateUrl: 'html/input/input_check/check_33_content.html'+'?datestamp=' + (new Date()).getTime(),
				replace: true,
				link: function(scope,element,attrs){
					console.log('check-33-content指令完成');
				}
			}
		});		
		app.directive('content35',function(){
			return {
				restrict: 'EA',
				templateUrl: 'html/input/input_check/check_35_content.html'+'?datestamp=' + (new Date()).getTime(),
				replace: true,
				link: function(scope,element,attrs){
					console.log('check-35-content指令完成');
				}
			}
		});
		
		app.directive('content36',function(){
			return {
				restrict: 'EA',		//指明指令在DOM里面以什么形式被声明,EA.表示即可以是元素也可以是属性
				templateUrl: 'html/input/input_check/check_36_content.html'+'?datestamp=' + (new Date()).getTime(),
				replace: true,		//设置解析后，DOM声明的指令是否消失
				link: function(scope,element,attrs){  //链接函数负责注册DOM事件和更新DOM,
					console.log('check-36-content指令完成');
				}
			}
		});
		app.directive('content37',function(){
			return {
				restrict: 'EA',
				templateUrl: 'html/input/input_check/check_37_content.html'+'?datestamp=' + (new Date()).getTime(),
				replace: true,
				link: function(scope,element,attrs){
					console.log('check-37-content指令完成');
				}
			}
		});
		app.directive('content38',function(){
			return {
				restrict: 'EA',		//指明指令在DOM里面以什么形式被声明,EA.表示即可以是元素也可以是属性
				templateUrl: 'html/input/input_check/check_38_content.html'+'?datestamp=' + (new Date()).getTime(),
				replace: true,		//设置解析后，DOM声明的指令是否消失
				link: function(scope,element,attrs){  //链接函数负责注册DOM事件和更新DOM,
					console.log('check-38-content指令完成');
				}
			}
		});
		app.directive('content39',function(){
			return {
				restrict: 'EA',
				templateUrl: 'html/input/input_check/check_39_content.html'+'?datestamp=' + (new Date()).getTime(),
				replace: true,
				link: function(scope,element,attrs){
					console.log('check-39-content指令完成');
				}
			}
		});
		app.directive('content40',function(){
			return {
				restrict: 'EA',
				templateUrl: 'html/input/input_check/check_40_content.html'+'?datestamp=' + (new Date()).getTime(),
				replace: true,
				link: function(scope,element,attrs){
					console.log('check-40-content指令完成');
				}
			}
		});
		app.directive('content43',function(){
			return {
				restrict: 'EA',
				templateUrl: 'html/input/input_check/check_43_content.html'+'?datestamp=' + (new Date()).getTime(),
				replace: true,
				link: function(scope,element,attrs){
					console.log('check-43-content指令完成');
				}
			}
		});
		app.directive('content45',function(){
			return {
				restrict: 'EA',
				templateUrl: 'html/input/input_check/check_45_content.html'+'?datestamp=' + (new Date()).getTime(),
				replace: true,
				link: function(scope,element,attrs){
					console.log('check-45-content指令完成');
				}
			}
		})

		app.directive('content47',function(){
			return {
				restrict: 'EA',
				templateUrl: 'html/input/input_check/check_47_content.html'+'?datestamp=' + (new Date()).getTime(),
				replace: true,
				link: function(scope,element,attrs){
					console.log('check-47-content指令完成');
				}
			}
		});

		app.directive('content50',function(){
			return {
				restrict: 'EA',		//指明指令在DOM里面以什么形式被声明,EA.表示即可以是元素也可以是属性
				templateUrl: 'html/input/input_check/check_50_content.html'+'?datestamp=' + (new Date()).getTime(),
				replace: true,		//设置解析后，DOM声明的指令是否消失
				link: function(scope,element,attrs){  //链接函数负责注册DOM事件和更新DOM,
					console.log('check-50-content指令完成');
				}
			}
		});	
		app.directive('content52',function(){
			return {
				restrict: 'EA',
				templateUrl: 'html/input/input_check/check_52_content.html'+'?datestamp=' + (new Date()).getTime(),
				replace: true,
				link: function(scope,element,attrs){
					console.log('check-52-content指令完成');
				}
			}
		})
		app.directive('content54',function(){
			return {
				restrict: 'EA',
				templateUrl: 'html/input/input_check/check_54_content.html'+'?datestamp=' + (new Date()).getTime(),
				replace: true,
				link: function(scope,element,attrs){
					console.log('check-54-content指令完成');
				}
			}
		});*/
		/************************************************************************************/

})(app)